﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.eforceglobal.crux.BusinessFacades;
using com.eforceglobal.crux.DTOs;
using com.eforceglobal.crux.security;
using com.eforceglobal.crux.views.Administration;

namespace com.eforceglobal.crux.controllers.Administration
{
    public class ChangeYourCompanyController
    {
        readonly IChangeYourCompany _view;
        public ChangeYourCompanyController(IChangeYourCompany view)
        {
            _view = view;
        }
         public void InitView(bool IsPostBack, int UserID)
        {
            if (!IsPostBack)
            {
                UserFacade facade = new UserFacade();
                SessionData sessionData = new SessionData();
                //CruxSecurityManager securityManager = new CruxSecurityManager();
                ICruxSecurityManager securityManager = CruxSecurityManagerFactory.GetSecurityManager();
                _view.AllowedCompanies = securityManager.GetCompaniesForUser(sessionData.CurrentUser.UserID); 
                _view.SelectCompanyID = sessionData.CurrentCompany.CompanyID;
            }
            
        }

         public CompanyInformation GetCompanyInformation(int companyID)
         {
             //CompanyFacade facade = new CompanyFacade();
             ICruxSecurityManager securityManager = CruxSecurityManagerFactory.GetSecurityManager();
             return securityManager.GetCompany(companyID);
         }
    }
}
